/*
 *  xbox360wireless_receiver.cpp
 *
 *  Created by Delio Brignoli on 10/12/08.
 *  Copyright 2008 Delio Brignoli. All rights reserved.
 *
 */

#include <IOKit/IOLib.h>
#include <IOKit/usb/IOUSBDevice.h>
#include "receiver.h"
#include "shared_state.h"

extern "C" {
#include <pexpert/pexpert.h>//This is for debugging purposes ONLY
}

// Define my superclass
#define super IOService

OSDefineMetaClassAndStructors(WReceiver, IOService)

bool WReceiver::start(IOService *provider)
{
    dIOLog(INFO, "Calling our superclass\n");
    bool res = super::start(provider);

    dIOLog(INFO, "Starting WReceiver\n");

	//Open the IOUSBDevice that is our provider
	//and attempt to set its configuration
	if (((IOUSBDevice*)provider)->open(this)) {
		//If setting the configuration succeeds the device's interfaces
		//will be matched to their specific devices (controller and headset)
		IOReturn ret = ((IOUSBDevice*)provider)->SetConfiguration(this,1);
		dIOLog(INFO, "Set config: %x\n", ret);
		((IOUSBDevice*)provider)->close(this);
	} else {
		dIOLog(INFO, "Failed to open the parent device\n");
	}

    return res;
}

void WReceiver::stop(IOService *provider)
{
    dIOLog(INFO, "Stopping\n");
    super::stop(provider);
}
